<template>
	<view class="user bg-grey">
		<view class="userInfo">
			<view v-if="userInfo.nickName" class="loginInfo">
					<image :src="userInfo.headImgUrl" mode=""></image>
					<view class="links p">
						{{userInfo.nickName}}
					</view>
			</view>
			<view class="loginInfo" v-else>
				<image src="https://m.xgimi.com/static/missing-face.png" mode=""></image>
				<view class="links p">
					<navigator url="../smsLogin/smsLogin">登录</navigator>/ <navigator url="../smsLogin/smsLogin.vue"   >注册</navigator>
				</view>
			</view>
		</view>
		<view class="card">
			<view class="title">我的订单</view>
		</view>
		<view class="card">
			<view class="title">常用工具</view>
		</view>
		<view v-if="userInfo.nickName" class="logout">退出登录</view>
	</view>
</template>

<script setup>
	 import {onShow} from '@dcloudio/uni-app'
	 import {checkLogin} from '../../api/auth.js'
	 import {ref} from 'vue'
	 const userInfo = ref({})
	 onShow(()=>{
		 checkLogin({
			 token:uni.getStorageSync("passToken"),
			 channel:"h5",
			 source:1			 
		 })
		 .then(res=>{
			 if(res.code===200){
				 userInfo.value = res.data;
				 console.log(res.data)
			 }
		 })
	 })
</script>

<style lang="scss" scoped>
.user{
  
}
.loginInfo{
	 display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 460rpx;
	image{
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		 
	}
	.links{
		display: flex;
	}
}
.card .title{
	font-size: 20px;
}
.logout{
	height: 90rpx;
	line-height: 90rpx;
	text-align: center;
	background-color: #fff;
	margin-bottom: 30rpx;
}
</style>
